<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- s设置用于路由操作的组件 -->
    <router-link to="/">首页</router-link>
    <router-link to="/user">用户</router-link>
    <router-link to="/pro">产品</router-link>
    <router-view></router-view>
  </div>
</body>
<script src="../lib/vue.js"></script>
<script src="./lib/vue-router.js"></script>
<script>

  var Index = {
    template: `<div>首页</div>`
  }
  var User = {
    template: `<div>用户</div>`
  }
  var Pro = {
    template: `<div>产品</div>`
  }

  // 定义路由规则
  var routes = [
    { path: '/', component: Index },
    { path: '/user', component: User },
    { path: '/pro', component: Pro }
  ]

  // 创建Vue Router实例
  var router = new VueRouter({
    routes
  })

  // 创建Vue实例,注入router
  new Vue({
    el: '#app',
    router: router,
    data: {

    }
  })
</script>
</html>